package com.bupt.liutong.admin.sch.dao;

import java.util.List;

import com.bupt.liutong.admin.core.base.Ibatis;
import com.bupt.liutong.admin.core.base.Photo;
import com.bupt.liutong.admin.core.base.PhotoDao;
import com.bupt.liutong.admin.sch.dto.IntroPhoto;

public class IntroPhotoDao implements PhotoDao {

	private Ibatis ibatis;

	@SuppressWarnings("unchecked")
	public List<IntroPhoto> getIntroPhotosByPage(IntroPhoto introPhoto) {
		return (List<IntroPhoto>) ibatis.queryForPage(
				"sch_intro_photo.getIntroPhotos", introPhoto);
	}
	
	@SuppressWarnings("unchecked")
	public List<IntroPhoto> getIntroPhotos() {
		return (List<IntroPhoto>) ibatis
				.queryForList("sch_intro_photo.getIntroPhotos");
	}

	public IntroPhoto getIntroPhotoById(int id) {
		return (IntroPhoto) ibatis.queryForObject(
				"sch_intro_photo.getIntroPhotoById", id);
	}

	public void insertIntroPhoto(IntroPhoto introPhoto) {
		ibatis.insert("sch_intro_photo.insertIntroPhoto", introPhoto);
	}

	public void updateIntroPhoto(IntroPhoto introPhoto) {
		ibatis.update("sch_intro_photo.updateIntroPhoto", introPhoto);
	}

	public void deleteIntroPhoto(int id) {
		ibatis.delete("sch_intro_photo.deleteIntroPhoto", id);
	}

	public void setIbatis(Ibatis ibatis) {
		this.ibatis = ibatis;
	}

	public Photo deletePhoto(Integer id) {
		Photo photo = this.getIntroPhotoById(id);
		this.deleteIntroPhoto(id);
		return photo;
	}

	public void insertPhoto(Photo photo) {
		this.insertIntroPhoto((IntroPhoto) photo);
	}

	public void updatePhoto(Photo photo) {
		this.updateIntroPhoto((IntroPhoto) photo);
	}
}
